import SparkMD5 from 'spark-md5';
export const getUploadFileMD5 = (file: File): Promise<string> => {
    return new Promise((resolve, reject) => {
        const fileReader = new FileReader();
        const spark = new SparkMD5.ArrayBuffer();

        fileReader.onload = (event) => {
            const arrayBuffer = event.target?.result as ArrayBuffer;
            spark.append(arrayBuffer);
            const md5Hash = spark.end(false);
            resolve(md5Hash);
        };

        fileReader.onerror = (error) => {
            reject(error);
        };

        fileReader.readAsArrayBuffer(file);
    });
};